<template>
    <div id="container" class="text-white text-sm bg-primary-300 min-h-screen pb-4"> 
        <Header/>
        <div class="text-center text-2xl p-8">
            激活你的账号
        </div>
        <div class="flex items-center justify-center">
            <div class="w-1/4 p-4 bg-gray-100 rounded-lg shadow-lg">
                <div class="text-black text-center p-4">
                    请点击下方按钮，激活账号
                </div>
                <div class="flex justify-center">
                    <button v-on:click="activate" class="bg-green-500 text-white px-4 py-2 rounded">激活账号</button> 
                </div>
            </div>
        </div>
        <Footer/>
    </div>
</template>

<script setup>
import Header from '@/components/Header.vue'
import Footer from '@/components/Footer.vue'
import { ref ,onMounted} from 'vue'
import { useRoute } from 'vue-router'
import { ElMessage } from 'element-plus'
import userApi from '@/api/user'
import { useRouter } from 'vue-router'

const route=useRoute()
const router=useRouter()

const activate=async()=>{
    const data={
        uid:route.params.udi,
        token:route.params.token
    }
    const res=await userApi.activate(data)
    if(res.code===200){
        ElMessage.success('账号激活成功')
        router.push('/login')
    }
}
onMounted(()=>{
    activate()
})



</script>